{extend name="platform/base" /}
{block name="resources"/}
<link rel="stylesheet" type="text/css" href="__STATIC__/blue/css/ns_table_style.css">
<style>
.table-class thead tr th{font-weight: bold;}
</style>
{/block}
{block name="main"}
<table class="table-class table table-striped b-light text-sm">
	<colgroup>
			<col width="3%">
			<col width="25%">
			<col width="25%">
			<col width="22%">
			<col width="25%">
	</colgroup>
	<thead>
		<tr align="left">
			<th class="center"><input type="checkbox" onclick="CheckAll(this)"></th>
			<th>名称</th>
			<th>描述</th>
			<th>类型</th>
			<th class="center">操作</th>
		</tr>
	</thead>
	<tbody></tbody>
</table>
{include file="platform/page" /}
{/block}
{block name="script"}
{include file="platform/page" /}
<script type="text/javascript">
$(function(){
	LoadingInfo(1);
});	
function LoadingInfo(page_index) {
	$.ajax({
		type : "post",
		url : "{:__URL('PLATFORM_MAIN/extend/hookslist')}",
		data : { "page_index" : page_index, "page_size" : $("#showNumber").val() },
		success : function(data) {
			$("#total_count_num").text(data["total_count"]);
			$("#page_count_num").text(data["page_count"]);
			$("#page_count").val(data["page_count"]);
			$("#pageNumber a").remove();
			var html = '';
			if (data['data'].length > 0) {
				for (var i = 0; i < data['data'].length; i++) {
					var type = '';
					if(data['data'][i]['type'] == 1){
						type = '视图';
					}else{
						type = '控制器';
					}
					html += '<tr>';
					html += '<td  style="text-align: center;"><input name="sub" type="checkbox" value="'+ data["data"][i]["id"]+'" ></td>';
					html += '<td>'+ data['data'][i]['name'] +'</td>';
					html += '<td>'+ data['data'][i]['description'] +'</td>';
					html += '<td>'+ type +'</td>';
					html += '<td class="center"><a href="'+__URL('PLATFORM_MAIN/extend/updatehooks?id='+data['data'][i]['id'])+'" style="margin-left:0;">修改</a>&nbsp;&nbsp;&nbsp;<a href="javascript:;" onclick="deleteHooks('+ data['data'][i]['id'] +')">删除</a></td>';
					html += '</tr>';
				}
			} else {
				html += '<tr align="center"><td colspan="4" style="text-align:center;">暂无钩子数据记录</td></tr>';
			}
			$(".table-class tbody").html(html);
			var totalpage = $("#page_count").val();
				if (totalpage == 1) {
					changeClass("all");
				}
				var $html = pagenumShow(jumpNumber,totalpage,{$pageshow})
				$("#pageNumber").append($html);
		}
	});
}

function deleteHooks(id){
	$("#dialog").dialog({
		buttons: {
			"确定": function() {
				$(this).dialog('close');
				$.ajax({
					type : "post",
					url : "{:__URL('PLATFORM_MAIN/extend/deleteHooks')}",
					data : { "id" : id },
					success : function(data) {
						if (data["code"] > 0) {
							showMessage('success', "删除成功","{:__URL('PLATFORM_MAIN/extend/hookslist')}");
						}else{
							showMessage('error', "删除失败");
						}
					}
				});
			},
			"取消,#e57373": function() {
				$(this).dialog('close');
			}
		},
		contentText:"你确定删除吗？",
		title:"消息提醒"
	});
}
</script>
{/block}